<template>
 <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
    </t-image-viewer>
    <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
    </van-image-preview>
  <div class="outline-parent">
   
    <img
      class="mirror"
      v-if="props.info.value || (props.info.video && props.info.video.url)"
      :src="publicUrls + 'free/style2/mirror.webp'"
      alt=""
    />
    <img
      class="outline-parent-bg"
      :src="publicUrls + 'free/style2/Auxiliaryoutlinestyle1Bg.webp'"
      alt=""
      v-if="props.info.value || (props.info.video && props.info.video.url)"
    />
    <img class="outline-parent-bg2" :src="publicUrls + 'free/style2/Auxiliaryoutlinestyle1-2Bg.webp'" alt="" v-else />
    <div class="outline border-hover-style" v-if="props.info.value || (props.info.video && props.info.video.url)">
      <div class="outline-box">
        <div class="outline-title">
          <span>{{ props.info.text }}</span>
          <div
            class="audio-box"
            :class="isPlay && 'audio-rotate'"
            v-if="props.info.audio && props.info.audio.url"
            @click="audioplay(true)"
          >
            <i class="doorIcon">&#xe688;</i>
          </div>
          <audio
            v-if="props.info.audio && props.info.audio.url"
            :src="urls + props.info.audio.url"
            ref="audioRef"
          ></audio>
        </div>
        <div class="outline-content">
          <div class="left-Text" v-if="props.info.subTitle || props.info.remarks">
            <p class="outline-subTitle" v-if="props.info.subTitle">
              {{ props.info.subTitle }}
            </p>
            <TextMax
              v-if="props.domShow"
              :data="props.info.remarks"
              :title="props.info.text"
              :infoData="props.info"
              :row="!props.info.subTitle ? 8 : 6"
            ></TextMax>
          </div>
          <div class="content-item" :style="!props.info.remarks && !props.info.subTitle && { marginLeft: 0 }">
            <div class="medium">
              <img
                v-if="props.info.value && !(props.info.video && props.info.video.url)"
                class="outline-cover"
                @click="ImgVisible = true"
                :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
                alt=""
              />
              <!-- <div class="mask-layer" v-show="isPlay && props.info.video && props.info.video.url" @click="videoplay">
                <div class="round">
                  <span v-if="isPlay" class="freeIcon">&#xe672;</span><span v-else class="freeIcon">&#xe671;</span>
                </div>
              </div> -->
              <!-- <video
                v-if="props.info.video && props.info.video.url"
                class="outline-cover"
                :src="urls + props.info.video.url"
                @click="videoplay"
                ref="videoRef"
              ></video> -->
              <videoview @click="audioplay(false)" :info="props.info"></videoview>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="outline outline2 border-hover-style" v-else>
      <div class="outline2-title">
        {{ props.info.text }}
        <div
          class="audio-box"
          :class="isPlay && 'audio-rotate'"
          v-if="props.info.audio && props.info.audio.url"
          @click="audioplay(true)"
        >
          <i class="doorIcon">&#xe688;</i>
        </div>
      </div>
      <p class="outline2-subTitle" v-if="props.info.subTitle">
        {{ props.info.subTitle }}
      </p>
      <TextMax
        v-if="props.domShow"
        :data="props.info.remarks"
        :title="props.info.text"
        :infoData="props.info"
        :row="
          !props.info.subTitle && props.info.text?.length < 9
            ? 6
            : !props.info.subTitle && props.info.text?.length > 9
            ? 5
            : 3
        "
      ></TextMax>
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free2Style1',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 30% linear-gradient(transparent, rgba(0, 0, 0, 0.15));
}
.mirror {
  position: absolute;
  top: 62px;
  left: 20px;
  width: 79px;
  height: 107px;
  z-index: 22;
}
.outline-parent-bg {
  width: 746px;
  height: 448px;
  margin-top: 50px;
  margin-right: 10px;
}
.outline {
  position: absolute;
  top: 50px;
  left: 0;
  z-index: 20;
  width: 746px;
  height: 448px;
  padding: 30px 66px 30px 30px;
}
.outline-box {
  width: 100%;
  height: 100%;
  border: 1px solid #212326;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.outline-title {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  border-bottom: 1px solid #212326;
  position: relative;
  span {
    font-family: FZYIKS--GB1, FZYIKS--GB1;
    font-size: 24px;
    color: #212326;
    line-height: 63px;
    text-align: center;
  }
}
.outline-content {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 30px;
  overflow: hidden;
}
.left-Text {
  width: 100%;
  height: 100%;
  // overflow: hidden;
}
.outline-subTitle {
  width: 100%;
  margin-bottom: 16px;
  font-family: SourceHanSerifCN;
  font-size: 18px;
  color: #212326;
  line-height: 28px;
  text-align: justify;
  opacity: 80%;
}
.content-item {
  position: relative;
  width: 100%;
  height: 100%;
  margin-left: 30px;
}
.medium {
  width: 100%;
  height: 100%;
  position: relative;

  .mask-layer {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    position: absolute;
    top: 50%;
    transform: translate(0%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    .round {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 2px solid rgba(255, 245, 228, 1);
      text-align: center;
      .freeIcon {
        font-size: 24px;
        line-height: 38px;
        color: rgba(255, 245, 228, 1);
      }
    }
  }
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: contain;
    overflow: hidden;
  }
}
.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: translate(0, -50%) rotate(0deg);
    }
    100% {
      transform: translate(0, -50%) rotate(360deg);
    }
  }
}
.audio-box {
  position: absolute;
  top: 50%;
  right: 28px;
  transform: translate(0, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #ffdc76;
  border-radius: 50%;
  box-shadow: 0px 2px 4px #0000001a;
  .doorIcon {
    font-size: 24px;
    color: #5b8c87;
  }
}

::v-deep .van-text-ellipsis {
  font-family: SourceHanSerifCN-Medium !important;
  font-size: 16px !important;
  color: rgba(33, 35, 38, 0.6) !important;
  line-height: 32px !important;
}
::v-deep .van-text-ellipsis__action::before {
  color: #ffdc76 !important;
  font-weight: 400 !important;
  text-decoration-line: underline;
}
::v-deep .t-popup__content {
  background: #5b8c87;
  box-shadow: none;
  padding: 4px 10px;
  font-size: 14px !important;
  line-height: 22px;
  color: #fff;
  box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.1), 0px 8px 10px 1px rgba(0, 0, 0, 0.06),
    0px 3px 14px 2px rgba(0, 0, 0, 0.05);
}
::v-deep .t-popup__arrow::before {
  background: #5b8c87;
  border: none;
  box-shadow: none !important;
}

.outline-parent-bg2 {
  width: 422px;
  height: 408px;
  margin-top: 78px;
}

.outline2 {
  width: 422px !important;
  height: 408px !important;
  padding: 66px 0 90px 0 !important;
  position: absolute;
  top: 78px !important;
  left: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  .outline2-title {
    width: 240px;
    font-family: FZYIKS--GB1, FZYIKS--GB1;
    font-size: 30px;
    color: #212326;
    line-height: 34px;
    text-align: center;
    margin-bottom: 16px;
    position: relative;
    .audio-box {
      right: -44px;
    }
  }
  .outline2-subTitle {
    width: 272px;
    margin-bottom: 16px;
    font-family: SourceHanSerifCN;
    font-size: 18px;
    color: #212326;
    line-height: 28px;
    text-align: center;
    opacity: 80%;
    margin-bottom: 16px;
  }
  ::v-deep .van-text-ellipsis__action::before {
    color: #ffdc76 !important;
  }
  ::v-deep .textMore-box {
    width: 272px;
  }
}
</style>
